class SubtouristsController < ApplicationController
   before_filter(:get_tourist)

  def create
    # Create a subtourist object that has
    # been instantiated with attributes
    # and linked to the tourist object
    @subtourist = @tourist.subtourists.build(params[:subtourist])
    @subtourist.img = session[:url]
    if @subtourist.save
      flash[:notice] = 'subtourist was successfully created.'
      respond_to do |format|
        format.html { redirect_to tourist_url(@tourist) }
        format.xml  { render :xml => @subtourist,
          :status => :created, :location => @tourist }
      end
    else
      flash[:notice] = 'subtourist was not created.'
      respond_to do |format|
        format.html { redirect_to tourist_url(@tourist) }
        format.xml  { render :xml => @subtourist.errors,
          :status => :unprocessable_entity }
      end
    end
  end

private

  def get_tourist
     @tourist = Tourist.find(params[:tourist_id])
  end

end
